package com.lxh.lxhcrm.model.dao.customer;

import com.lxh.lxhcrm.model.pojos.Customer;
import com.lxh.lxhcrm.model.vo.CustomerVO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CusDao extends CrudRepository<Customer, Integer> {
    /**
     * 单纯的查询所有客户
     * @author 鞠玮
     * @return List<Customer>
     */
    @Query("select new com.lxh.lxhcrm.model.vo.CustomerVO(c.customerId,c.customerName) from Customer c")
    List<CustomerVO> findAllCustomer();

    @Query("select new com.lxh.lxhcrm.model.vo.CustomerVO(c.customerId,c.customerName,c.cusStage.stageId) from Customer c " +
            "where c.customerId = ?1")
    CustomerVO findByCustomerId(Integer customerId);
}
